﻿using System;
using UnityEngine;

[ExecuteInEditMode, RequireComponent(typeof(Camera))]
public class CopyFromMainCamera : MonoBehaviour
{
    private Camera cam;
    private Camera m_mainCam;
    private Transform m_mainCamTsm;
    private Transform tsm;

    private void Awake()
    {
        this.cam = base.GetComponent<Camera>();
        this.tsm = base.transform;
    }

    private void OnPreRender()
    {
        if (this.mainCamTsm != null)
        {
            this.tsm.position = this.mainCamTsm.position;
            this.tsm.eulerAngles = this.mainCamTsm.eulerAngles;
            this.cam.orthographicSize = this.mainCam.orthographicSize;
        }
    }

    private Camera mainCam
    {
        get
        {
            return ((this.m_mainCam == null) ? (this.m_mainCam = Camera.main) : this.m_mainCam);
        }
    }

    private Transform mainCamTsm
    {
        get
        {
            return ((this.m_mainCamTsm == null) ? (this.m_mainCamTsm = (this.mainCam == null) ? null : this.mainCam.transform) : this.m_mainCamTsm);
        }
    }
}

